﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var cols = [
	{col:{header:'*任务号', width:68, sortable:true, align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatInt()}, field:{name:'project_plan__task_no',type:'string'}},
	{col:{header:'*任务内容', width:253, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.TextField({
			maxLength:200, allowBlank:false
		})}, field:{name:'project_plan__task_content',type:'string'}},
	{col:{header:'*计划开始日期', width:100, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.DateField({
			format: 'Y-m-d', allowBlank:false,
			minValue: '1900-01-01'
		}),
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'project_plan__start_date',type:'date'}},
	{col:{header:'*计划结束日期', width:100, sortable:true, editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.DateField({
			format: 'Y-m-d', allowBlank:false,
			minValue: '1900-01-01'
		}),
		renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'project_plan__end_date',type:'date'}},
	{col:{header:'计划工期(天)', width:98, sortable:true, defaultval:'0', align:'right',
		editable:false,
		editor:new Ext.form.NumberField({
			maxLength:12
		}),renderer:JxUtil.formatInt()}, field:{name:'project_plan__project_day',type:'int'}},
	{col:{header:'前置任务号', width:91, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			maxLength:12
		}),renderer:JxUtil.formatInt()}, field:{name:'project_plan__pre_no',type:'string'}},
	{col:{header:'父任务号', width:71, sortable:true, align:'right',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.NumberField({
			maxLength:12
		}),renderer:JxUtil.formatInt()}, field:{name:'project_plan__parent_no',type:'string'}},
	{col:{header:'负责人', width:107, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TriggerField({
			maxLength:20,
			editable:false,
			triggerClass:'x-form-search-trigger', 
			onTriggerClick: function() {
				var selcfg = {pageType:'combogrid', nodeId:'sys_user', layoutPage:'/public/layout/layout_tree.js', sourceField:'sys_user.user_name;user_id', targetField:'project_plan.project_user;project_userid', whereSql:"", whereValue:'', whereType:'', isSame:'0', isShowData:'1', isMoreSelect:'0',isReadonly:'1',fieldName:'project_plan.project_user'};
				JxSelect.createSelectWin(selcfg, this, 'node_project_plan_editgrid');
			}
		})}, field:{name:'project_plan__project_user',type:'string'}},
	{col:{header:'是否里程碑', width:86, sortable:true, hidden:true, defaultval:'0'}, field:{name:'project_plan__is_milestone',type:'string'}},
	{col:{header:'是否质量检查', width:100, sortable:true, hidden:true, defaultval:'0'}, field:{name:'project_plan__is_qualitycheck',type:'string'}},
	{col:{header:'是否付款相关', width:100, sortable:true, hidden:true, defaultval:'0'}, field:{name:'project_plan__is_pay',type:'string'}},
	{col:{header:'风险等级', width:100, sortable:true, hidden:true}, field:{name:'project_plan__warn_level',type:'string'}},
	{col:{header:'负责人ID', width:100, sortable:true, hidden:true}, field:{name:'project_plan__project_userid',type:'string'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'project_plan__plan_id',type:'string'}},
	{col:{header:'编制ID', width:100, sortable:true, hidden:true}, field:{name:'project_plan__mplan_id',type:'string'}},
	{col:{header:'实际开始日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'project_plan__done_sdate',type:'date'}},
	{col:{header:'竣工日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'project_plan__done_edate',type:'date'}},
	{col:{header:'实际工期(天)', width:100, sortable:true, hidden:true, renderer:JxUtil.formatInt()}, field:{name:'project_plan__done_day',type:'int'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '0',
		funid: 'project_plan'
	};
	
	config.initpage = function(gridNode) {
		var grid = gridNode.page;
		
		grid.on('afteredit', function(e){
			var record = e.record;
			if (e.field == 'project_plan__start_date' || e.field == 'project_plan__end_date') {
				//计划开始日期
				var sd = record.get('project_plan__start_date');
				if (sd == null) return;
				//计划结束日期
				var ed = record.get('project_plan__end_date');
				if (ed == null) return;
				
				//计算工期
				var dd = parseInt(ed.getElapsed(sd) / 1000 / 60 / 60 / 24) + 1;
				
				record.set('project_plan__project_day', dd);

				record.set('project_plan__done_sdate', sd);
				record.set('project_plan__done_edate', ed);
				record.set('project_plan__done_day', dd);
			}
		});
	};
		
	return new Jxstar.GridNode(config);
}